package com.usian.article.controller.v1;

import com.usian.apis.article.ArticleHomeControllerApi;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.common.constants.ArticleConstans;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/v1/article")
public class ArticleHomeController implements ArticleHomeControllerApi {

    @Autowired
    private ApArticleService apArticleServiceI;

    /**
      * 功能描述：加载首页
      * @param:
      * @return：
      * @auther：
      */
    @Override
    @PostMapping("load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleServiceI.load(dto, ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    /**
     * 功能描述：加载更多
     * @param:
     * @return：
     * @auther：
     */
    @Override
    @PostMapping("loadmore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleServiceI.load(dto, ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    /**
     * 功能描述：加载最新
     * @param:
     * @return：
     * @auther：
     */
    @Override
    @PostMapping("loadnew")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleServiceI.load(dto, ArticleConstans.LOADTYPE_LOAD_NEW);
    }
}
